<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<link rel="stylesheet" href="./css/login.css">
<script src="../lib/jquery/jquery-1.12.4.min.js"></script>
<script src="./url.js"></script>
<body>
    <div class="wrap">
        <div class="head">
            <h1>
                <img src="./images/logo.jpg" alt="">
                美发管理系统
            </h1>
        </div>
        <form action="post">
            <div class="middle">
                <div class="top">
                    <span>用户名</span>
                    <input type="text" name="username" class="user_name">
                </div>
                <div class="center">
                    <span>&nbsp;&nbsp; 密码</span>
                    <input type="text" name="password" class="password">
                </div>
            </div>
            <div class="foot">
                <div>
                    <button class="test1">登录</button>
                    <button class="test2">注册</button>
                </div>
            </div>
        </form>
    </div>
    <script>
        $(".test1").click((e)=>{
            e.preventDefault()
            $.ajax({
                method:"post",
                url:`${Baseurl}/login`,
                data:{
                    username:$(".user_name").val(),
                    password:$(".password").val()
                    
                },
                success:function(data){
                    console.log(data);
                    if(data=="登录成功"){
                        window.location="./index.html"
                    }else{
                        alert("用户名或登录错误")
                    }
                }
            })
        })
        $(".test2").click((e)=>{
            e.preventDefault()
            window.location="./register.html"
        })
    </script>
</body>

</html>